-- Read the docs: https://www.lunarvim.org/docs/configuration
-- Example configs: https://github.com/LunarVim/starter.lvim
-- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6
-- Forum: https://www.reddit.com/r/lunarvim/
-- Discord: https://discord.com/invite/Xb9B4Ny

local config_path = vim.fn.stdpath("config")
require("luasnip.loaders.from_lua").load({ paths = config_path .. "/snippets" })

-----Desc:基础配置相关---------------------------------------------
require("config.keymaps").config()
require("config.autocmd").config()
require("config.options").config()

-----Desc:Ide继承---------------------------------------------
require("ide.gopher").config()

-- 自动加载插件
local plugins_dir = config_path .. "/plugins"
local ft = require("tool.file")
if not ft.dirExists(plugins_dir) then
  ft.mkDirs(plugins_dir)
end
local scan = require("plenary.scandir") -- 使用 plenary 插件扫描目录
local files = scan.scan_dir(plugins_dir, {
  depth = 1,
  add_dirs = false,
  hidden = false
})
package.path = package.path .. ";" .. plugins_dir .. "/?.lua"
for _, file in ipairs(files) do
  if file:match("%.lua$") then -- 检查是否是 .lua 文件
    local ok, p = pcall(dofile, file)
    if ok and p then
      if type(p) == "table" or type(p) == "string" then
        lvim.plugins = lvim.plugins or {}
        table.insert(lvim.plugins, p)
      end
    end
  end
end
